/**
 * @param {number[][]} matches
 * @return {number[][]}
 */
var findWinners = function (matches) {
    let m = {}
    for (let i = 0; i < matches.length; i++) {
        if (!m[matches[i][0]]) m[matches[i][0]] = 0
        if (m[matches[i][1]]) m[matches[i][1]]--
        else m[matches[i][1]] = -1
    }
    let res = [[], []]
    Object.keys(m).forEach(k => {
        if (m[k] == 0) res[0].push(parseInt(k))
        else if (m[k] == -1) res[1].push(parseInt(k))
    })
    res[0].sort((a, b) => a - b)
    res[1].sort((a, b) => a - b)
    return res
};